/*
 * @(#)Node.java 1.50 04/04/14
 * 
 * Clase Compartida
 * PROP Grupo 13 Cluster 3
 */

/**
 * Esta clase implementa una estructura de datos pensada para ser usada como v�rtice
 * del grafo a recorrer, es por esto que contiene una List de Cost que almacena la
 * distancia del nodo indicaco en el parametro implicito hacia cualquier otro nodo
 * con el que tenga aristA
 * 
 * @author David Molins Gom�
 */

package dominio;


import java.util.ArrayList;


public class Node extends GraphElement {

	public Integer time = 0; //predefino por defecto 0 el costo de ejecucion de un Nodo
	public ArrayList<Cost> costs;
	private Cost c;
	public Integer cost;
	
	
	//Creadoras
	
	public Node() {}

	public Node (Integer id){
        super(id);
        this.id = id;
    }

    public Node (Integer id, String name, String description){
        super(id, name, description);
        this.id = id;
        this.name = name;
        this.description = description;
        this.costs = new ArrayList<Cost>();
    }

    public Node (Integer id, String name, String description, Integer cost){
        super(id, name, description);
		this.id = id;
		this.name = name;
		this.description = description;
		//this.time = time;
		this.time = cost;
		this.costs = new ArrayList<Cost>();
	}

    public Node (Integer id, String name, String description, ArrayList<Cost> costs){
        super(id, name, description, costs);
        this.id = id;
        this.name = name;
        this.description = description;
        this.costs = costs;
    }
	

	public Node (Integer id, String name, String description, Integer time, ArrayList<Cost> costs){
        super(id, name, description, costs);
        this.id = id;
		this.name = name;
		this.description = description;
		this.time = time;
        this.costs = costs;
	}

	//Setters

	public void SetTime (Integer NewTime){
		time = NewTime;
	}

	public void SetCosts (ArrayList<Cost> NewCosts){
        SetGraphElementCostsList(NewCosts);
		costs = NewCosts;
	}


	//Getters
	public Integer GetId(){
		return this.id;
	}

	public String GetName(){
		return this.name;
	}

	public String GetDescription(){
		return description;
	}

	public Integer GetTime(){
		return this.time;
	}

	public ArrayList<Cost> GetCosts(){
		return this.costs;
	}

	public Integer GetCostTo(Integer id){ // Devuelve el coste de ir del parametro implicito al nodo de id = id sino hay camino posible devuelve -1
		if(!this.costs.isEmpty()){
			for(Cost i : this.costs){
				if (i.GetId() == id){
					return i.GetCost();
				}
			}
		}
		return -1;
	}	

	
	public void PrintNode(){
		System.out.println("[node]id: "+this.id);
		System.out.println("[node]name: "+this.name);
		System.out.println("[node]description: "+this.description);
		System.out.println("[node]time: "+this.cost);
		System.out.println("[node]costs: ");
		PrintCosts(this.costs);
		System.out.println("\n");
	}
	
	public void PrintCosts(ArrayList<Cost> costes){
		for(Integer i = 0; i < costes.size(); i++){
			c = costes.get(i);
			c.PrintCost();//System.out.println("[id:"+c.id+"]="+c.cost+" ");
		}
	}
}
